package com.ug_project.views

import android.content.Context
import android.os.Build
import android.support.annotation.RequiresApi
import android.util.AttributeSet
import android.widget.CheckedTextView

/**
 * Created by yeganaaa on 17-1-22.
 */

open class CheckedTextView : CheckedTextView, INew_View {

    override var _font: String? = null

    constructor(context: Context) : super(context) {
        Initialize(context, null)
    }

    constructor(context: Context, attrs: AttributeSet) : super(context, attrs) {
        Initialize(context, attrs)
    }

    constructor(context: Context, attrs: AttributeSet, defStyleAttr: Int) : super(context, attrs, defStyleAttr) {
        Initialize(context, attrs)
    }

    @RequiresApi(api = Build.VERSION_CODES.LOLLIPOP)
    constructor(context: Context, attrs: AttributeSet, defStyleAttr: Int, defStyleRes: Int) : super(context, attrs, defStyleAttr, defStyleRes) {
        Initialize(context, attrs)
    }

    private fun Initialize(_context: Context, attrs: AttributeSet?)
    {
        var attr = context.obtainStyledAttributes(attrs, R.styleable.CheckedTextView)

        val xmlFont = attr.getString(R.styleable.CheckedTextView_customizedfont)
        _font = if (!xmlFont.isNullOrEmpty()) xmlFont else FONT_NAME
        font = _font
    }
}